<%@ page contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="com.sinodata.bsm.common.vo.Probe"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>prop变更</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta http-equiv="pragma" content="no-cache"/>
	<meta http-equiv="cache-control" content="no-cache"/>
	<meta http-equiv="expires" content="0"/> 
	<%@ include file="../include/common.jsp"%>
	<%@ include file="../include/jbox.jsp"%>
	
	
    <link rel="stylesheet" type="text/css"
	      href="${pageContext.request.contextPath}/style/default/select/jquery.image.select.css" />
	<script type="text/javascript"
	      src="${pageContext.request.contextPath}/js/select/jquery.image.select.min.js"></script>
	      
	<script type="text/javascript">
		function cancel(){
			getTopWin(window).closejBox('probeChange');
		}
		function change(value){
			if(value==1){
				$('#changeTr').hide();
				$("#relation").removeAttr('disabled');
			}else{
				$('#changeTr').show();
				$("#relation").attr('disabled','disabled').removeAttr('checked');
			}
		}
		
		function save(){
			var val = $("input[name='type']:checked").val();
			var entity = new Object ;
			entity.selectedVal = val;
			if(val==1){
				entity.currentProbe = '';
				entity.newProbe   = $('#newProbe').val();
			}else{
				if($('#currentProbe').val()==$('#newProbe').val()){
					$.jBox.alert("probe相同,变更无意义!","提示",{width:150});
					return false;
				}
			
				entity.currentProbe = $('#currentProbe').val();
				entity.newProbe   = $('#newProbe').val();
			}
			entity.relation = $("#relation").is(':checked');
			
			var resIpChangeWin = getTopWin(window).currentWin['probeChange'];
			resIpChangeWin.probeChange(entity);
			getTopWin(window).closejBox('probeChange');
		}
		
		$(document).ready(function(){
			var isSelect = '${isSelected}';
			if(isSelect==''){
				$("input[name='type']").eq(1).attr('checked','checked');
				$("input[name='type']").eq(0).attr('disabled','disabled');
				$("#relation").attr('disabled','disabled');
				$('#changeTr').show();
			}else{
				$("input[name='type']").eq(0).attr('checked','checked');
				$('#changeTr').hide();
			}
			
			//显示probe状态
			$("#currentProbe").msDropDown().data("dd");
			$("#newProbe").msDropDown().data("dd");
			
		});
		
	</script>

  </head>
  
  <body style="padding:5px;" >
	   		<table class="table_eidt" >
				<tbody>
					<tr>
						<td style="width:50%">
						     <input type="radio" name="type" id="forres" value="1" onclick="change(this.value)" />
							 <label for="forres">按资源变更</label>
						</td>
						<td style="width:50%">
						     <input  type="checkbox"  name="relation" id="relation"  />
						     <label for="relation">递归变更子资源</label>
						</td>
					</tr>
					<tr>
					    <td colspan="2"><input  type="radio" name="type" id="forprobe" value="2" onclick="change(this.value)"  />
							 <label for="forprobe">按probe变更</label>
						</td>
						
					</tr>
					<tr id="changeTr">
						<td class="td_left">原Probe</td>
						<td class="td_right">
							<select id="currentProbe" name="currentProbe" class="input_text" >
								<%
									List<Probe> probes = (List<Probe>)request.getAttribute("probes");
							                 for(Probe  p : probes){
			      	    						    if(p.getStatus()==3){
			      	  	    			    				out.println("<option value='"+p.getId()+"' title='/bsm/style/default/bsm/images/proberun.png' >"+p.getId()+"_"+p.getName()+"</option>");
			      	  	    						    }else{
			      	  	  	    			    			out.println("<option value='"+p.getId()+"' title='/bsm/style/default/bsm/images/probestop.png' >"+p.getId()+"_"+p.getName()+"</option>");
			      	  	    						 }
							                 }
								 %>
							</select>
						</td>
					</tr>
					<tr>
						<td class="td_left" >新Probe</td>
						<td class="td_right" >
							<select id="newProbe" name="newProbe" class="input_text" >
								<%
							   for(Probe  p : probes){
		  						    if(p.getStatus()==3){
	    			    				out.println("<option value='"+p.getId()+"' title='/bsm/style/default/bsm/images/proberun.png' >"+p.getId()+"_"+p.getName()+"</option>");
	    						    }else{
	  	    			    			out.println("<option value='"+p.getId()+"' title='/bsm/style/default/bsm/images/probestop.png' >"+p.getId()+"_"+p.getName()+"</option>");
	    						    }
                                }
								 %>
							</select>
						</td>
					</tr>
				</tbody>
			</table>
	   <div class="btn-div" >
	   			<input type="button" value="保存" onclick="save()" class="btn-4"  /> 
	   			<input type="button" value="取消" onclick="cancel()" class="btn-4" />
	  </div>
  </body>
</html>
